import Mock from 'mockjs'
import homeApi from './mockServerData/home'
import UserApi from './mockServerData/user'
//定义mock请求拦截
// Mock.mock('/api/home/getData',function(){
//     //拦截到请求后的处理逻辑
//     console.log("拦截到了")
// })

Mock.mock('/api/home/getData',homeApi.getStatisticalData)
Mock.mock('/api/user/getUser',UserApi.getAllData)
// Mock.mock('/api/user/addUser',UserApi.addData(data))
Mock.mock('/api/user/addUser', 'post', (options) => {
    // 获取请求体数据
    const postData = JSON.parse(options.body);
  
    // 输出请求体数据到控制台，方便查看
    console.log('Received POST data:', postData);
    UserApi.addData(postData);
  });

Mock.mock('/api/user/updateUser', 'post', (options) => {
    // 获取请求体数据
    const postData = JSON.parse(options.body);
  
    // 输出请求体数据到控制台，方便查看
    console.log('Received POST data:', postData);
    UserApi.updateData(postData);
});

Mock.mock('/api/user/deleteUser', 'post', (options) => {
    // 获取请求体数据
    const postData = JSON.parse(options.body);
  
    // 输出请求体数据到控制台，方便查看
    console.log('Received POST data:', postData);
    UserApi.deleteData(postData);
});

